<?php
/* -------------------------------------------------------------------------------------
* 	ID:						$Id: orders_edit_options.php 79 2013-09-21 12:02:29Z phone.mueller@googlemail.com $
* 	Letzter Stand:			$Revision: 79 $
* 	zuletzt geaendert von:	$Author: siekiera $
* 	Datum:					$Date: 2013-09-21 12:02:29 +0000 (Sat, 21 Sep 2013) $
*
* 	SEO:mercari by Siekiera Media
* 	http://www.seo-mercari.de
*
* 	Copyright (c) since 2011 SEO:mercari
* --------------------------------------------------------------------------------------
* 	based on:
* 	(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	(c) 2002-2003 osCommerce - www.oscommerce.com
* 	(c) 2003     nextcommerce - www.nextcommerce.org
* 	(c) 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* ----------------------------------------------------------------------------------- */

if(!$_GET['oID'])
	$_GET['oID'] = $_POST['oID'];
	
$order = new order($_GET['oID']);

$attributes = $db->db_query("SELECT 
									* 
								FROM 
									".TABLE_ORDERS_PRODUCTS_ATTRIBUTES." 
								WHERE 
									orders_id = '".$_GET['oID']."' 
								AND 
									orders_products_id = '".$_GET['opID']."'");
?>
<table width="100%" cellpadding="2" class="dataTable">
	<tr class="dataTableHeadingRow">
		<th class="dataTableHeadingContent"><?php echo TEXT_PRODUCT_OPTION;?></th>
		<th class="dataTableHeadingContent"><?php echo TEXT_PRODUCT_OPTION_VALUE;?></th>
		<th class="dataTableHeadingContent"><?php echo TEXT_PRICE.TEXT_SMALL_NETTO;?></th>
		<th class="dataTableHeadingContent"><?php echo TEXT_PRICE_PREFIX;?></th>
		<th class="dataTableHeadingContent">&nbsp;</th>
		<th class="dataTableHeadingContent">&nbsp;</th>
		<th class="dataTableHeadingContent">&nbsp;</th>
	</tr>
	<?php while(!$attributes->EOF) { ?>
	<tr class="dataTableRow">
		<?php
			echo draw_form('product_option_edit', FILENAME_ORDERS_EDIT, 'action=product_option_edit', 'post');
			echo draw_hidden_field('menu', $_GET['menu']);
			echo draw_hidden_field('oID', $_GET['oID']);
			echo draw_hidden_field('opID', $_GET['opID']);
			echo draw_hidden_field('pID', $_GET['pID']);
			echo draw_hidden_field('opAID', $attributes->fields['orders_products_attributes_id']);
		?>
		<td><?php echo draw_input_field('products_options', $attributes->fields['products_options'], 'size="20"');?></td>
		<td><?php echo draw_input_field('products_options_values', $attributes->fields['products_options_values'], 'size="20"');?></td>
		<td><?php echo draw_input_field('options_values_price',$attributes->fields['options_values_price'], 'size="10"');?></td>
		<td align="center"><?php echo $attributes->fields['price_prefix'];?></td>
		<td>
			<select name="prefix" style="width:auto">
				<option value="+">+</option>
				<option value="-">-</option>
			</select>
		</td>
		<td>
		<?php
			echo '<button type="submit" class="button" onclick="this.blur();">'.BUTTON_SAVE.'</button>';
			echo '</form>';
		?>
	</td>
	<td>
		<?php
			echo draw_form('product_option_delete', FILENAME_ORDERS_EDIT, 'action=product_option_delete', 'post');
			echo draw_hidden_field('menu', $_GET['menu']);
			echo draw_hidden_field('oID', $_GET['oID']);
			echo draw_hidden_field('opID', $_GET['opID']);
			echo draw_hidden_field('opAID', $attributes->fields['orders_products_attributes_id']);
			echo '<button type="submit" class="button" onClick="this.blur();">'.BUTTON_DELETE.'</button>';
			echo '</form>';
		?>
	</td>
	</tr>
	<?php 
		$attributes->MoveNext();
	} ?>
</table>
<br /><br />

<table border="0" width="100%" cellspacing="0" cellpadding="2">
<?php
     $products = $db->db_query("SELECT
									products_attributes_id,
									products_id,
									options_id,
									options_values_id,
									options_values_price,
									price_prefix
								FROM
									".TABLE_PRODUCTS_ATTRIBUTES."
								WHERE
									products_id = '".$_GET['pID']."'
								ORDER BY
									options_id");

?>
<h3>Verfügbare Attribute dieses Produktes</h3>
<table width="100%" cellpadding="2" class="dataTable">
	<tr class="dataTableHeadingRow">
		<th class="dataTableHeadingContent"><nobr>Attr-Id</nobr></th>
		<th class="dataTableHeadingContent">Option</th>
		<th class="dataTableHeadingContent">Wert</th>
		<th class="dataTableHeadingContent"><?php echo TEXT_PRICE;?></th>
		<th class="dataTableHeadingContent">&nbsp;</th>
	</tr>
	<?php while(!$products->EOF) { ?>
		<tr class="dataTableRow">
			<?php
			echo draw_form('product_option_ins', FILENAME_ORDERS_EDIT, 'action=product_option_ins', 'post');
			echo draw_hidden_field('oID', $_GET['oID']);
			echo draw_hidden_field('opID', $_GET['opID']);
			echo draw_hidden_field('pID', $_GET['pID']);
			echo draw_hidden_field('aID', $products->fields['products_attributes_id']);
		
			$brutto = PRICE_IS_BRUTTO;
			if($brutto == 'true')
				$options_values_price = round(($products->fields['options_values_price']*(1+($_GET['pTX']/100))), PRICE_PRECISION);
			else
				$options_values_price = round($products->fields['options_values_price'], PRICE_PRECISION);
			?>
			<td class="dataTableContent" width="1" align="center"><?php echo $products->fields['products_attributes_id'];?></td>
			<td class="dataTableContent"><?php echo oe_get_options_name($products->fields['options_id']);?></td>
			<td class="dataTableContent"><?php echo oe_get_options_values_name($products->fields['options_values_id']);?></td>
			<td class="dataTableContent">
				<?php echo draw_hidden_field('options_values_price', $products->fields['options_values_price']);?>
				<?php echo $price->format($price->CalculateCurr($options_values_price),true);?>
			</td>
			<td class="dataTableContent" width="1">
				<?php
					echo '<button type="submit" class="button" onclick="this.blur();">'.BUTTON_INSERT.'</button>';
					echo '</form>';
				?>
			</td>
		</tr>
		<?php 
		$products->MoveNext();
	} ?>
</table><br />